package itheima;

import org.junit.jupiter.api.Test;

public class testThreadlocal {
    @Test
    public void testThreadLocal(){
        ThreadLocal tl = new ThreadLocal();

        new Thread(()->{
            tl.set("a");
            System.out.println(Thread.currentThread().getName()+" "+tl.get());
            System.out.println(Thread.currentThread().getName()+" "+tl.get());
            System.out.println(Thread.currentThread().getName()+" "+tl.get());
        },"t1").start();

        new Thread(()->{
            tl.set("b");
            System.out.println(Thread.currentThread().getName()+" "+tl.get());
            System.out.println(Thread.currentThread().getName()+" "+tl.get());
            System.out.println(Thread.currentThread().getName()+" "+tl.get());
        },"t2").start();
    }
}
